<template>
  <div style="padding: 16px;">
    <div
      style="font-size: 16px;font-weight: 600;color: #1D2129;margin-bottom: 16px;"
    >
      业余训练情况-体校数据
    </div>
    <div style="display: flex;">
      <div style="height: 100px;width:100%;display: flex;">
        <div style="display: flex;margin-top: 32px; width:25%;">
          <img
            src="@/assets/img/Frame@2x.png"
            alt=""
            style="width: 31px;height: 31px;margin-top: 7px;margin-right: 15px;"
          />
          <div>
            <div style="font-size: 24px;color: #0F0F0F;">34,201</div>
            <div>体育传统项目学校</div>
          </div>
        </div>
        <div style="display: flex;margin-top: 32px;width:25%;">
          <img
            src="@/assets/img/Frame@2x.png"
            alt=""
            style="width: 31px;height: 31px;margin-top: 7px;margin-right: 15px;"
          />
          <div>
            <div style="font-size: 24px;color: #0F0F0F;">34,201</div>
            <div>指导教师数量/人</div>
          </div>
        </div>
        <div style="display: flex;margin-top: 32px;width:25%;">
          <img
            src="@/assets/img/Frame@2x.png"
            alt=""
            style="width: 31px;height: 31px;margin-top: 7px;margin-right: 15px;"
          />
          <div>
            <div style="font-size: 24px;color: #0F0F0F;">34,201</div>
            <div>年组织活动总次数/次</div>
          </div>
        </div>
        <div style="display: flex;margin-top: 32px;width:25%;">
          <img
            src="@/assets/img/Frame@2x.png"
            alt=""
            style="width: 31px;height: 31px;margin-top: 7px;margin-right: 15px;"
          />
          <div>
            <div style="font-size: 24px;color: #0F0F0F;">34,201</div>
            <div>年组织活动总次数/次</div>
          </div>
        </div>
      </div>

      <!-- <div
        style="height: 296px;width:50%;display: flex; border-left: 1px solid  rgba(129,129,129,0.15);"
      >
        <div ref="chart" style="height: 300px;width:100%"></div>
      </div> -->
    </div>
    <div
      style="background: #F3F3F3; width: 100%;height: 35px;line-height: 40px;display: flex;justify-content: space-between;"
    >
      <el-radio-group v-model="activeTab" size="small" @change="datalist">
        <el-radio-button label="1">体育运动学校</el-radio-button>
        <el-radio-button label="2">竞技体校</el-radio-button>
        <el-radio-button label="3">少儿体校</el-radio-button>
        <el-radio-button label="4">单项体校</el-radio-button>
        <el-radio-button label="5">体育中学</el-radio-button>
      </el-radio-group>
    </div>

    <div
      style="height:200px; width:100%;background: #F9F9F9; margin-top: 15px; padding: 0 12px; display: flex;"
    >
      <div
        style="height: 200px;width:25%;border-right: 1px solid rgba(129,129,129,0.15);"
      >
        <div
          style="width:100px; height:40px;font-size: 14px;color: #000000;margin-left: 24%; line-height: 40px;"
        >
          体校数量
        </div>
        <div style="display: flex;width:100%; ">
          <div ref="chart" style="width:60%;height:160px"></div>
          <div
            style="width:40%;height:160px;padding: 31px 10px; display: flex; flex-wrap: wrap;justify-content: space-between;"
          >
            <div style="display: flex;" v-for="(item, index) in namedata">
              <div
                :style="{ backgroundColor: item.color }"
                class="dianidan"
              ></div>
              <div>
                <div style="font-size: 12px;margin-right: 7px; width: 61px;">
                  {{ item.name }}
                </div>
                <div style="font-size: 22px;color: #0F0F0F;">
                  {{ item.value }}
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div
        style="height: 200px;width:25%;border-right: 1px solid rgba(129,129,129,0.15);"
      >
        <div
          style="width:100px; height:40px;font-size: 14px;color: #000000;margin-left: 24%; line-height: 40px;"
        >
          在训运动员数量
        </div>
        <div style="display: flex;width:100%; ">
          <div ref="chart2" style="width:60%;height:160px"></div>
          <div
            style="width:40%;height:160px;padding: 31px 10px; display: flex; flex-wrap: wrap;justify-content: space-between;"
          >
            <div style="display: flex;" v-for="(item, index) in namedata">
              <div
                :style="{ backgroundColor: item.color }"
                class="dianidan"
              ></div>
              <div>
                <div style="font-size: 12px;margin-right: 7px; width: 61px;">
                  {{ item.name }}
                </div>
                <div style="font-size: 22px;color: #0F0F0F;">
                  {{ item.value }}
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div
        style="height: 200px;width:25%;border-right: 1px solid rgba(129,129,129,0.15);"
      >
        <div
          style="width:100px; height:40px;font-size: 14px;color: #000000;margin-left: 24%; line-height: 40px;"
        >
          教练员数量
        </div>
        <div style="display: flex;width:100%; ">
          <div ref="chart3" style="width:60%;height:160px"></div>
          <div
            style="width:40%;height:160px;padding: 31px 10px; display: flex; flex-wrap: wrap;justify-content: space-between;"
          >
            <div style="display: flex;" v-for="(item, index) in namedata">
              <div
                :style="{ backgroundColor: item.color }"
                class="dianidan"
              ></div>
              <div>
                <div style="font-size: 12px;margin-right: 7px; width: 61px;">
                  {{ item.name }}
                </div>
                <div style="font-size: 22px;color: #0F0F0F;">
                  {{ item.value }}
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div style="height: 200px;width:25%;">
        <div
          style="width:100px; height:40px;font-size: 14px;color: #000000;margin-left: 24%; line-height: 40px;"
        >
          文化教师数量
        </div>
        <div style="display: flex;width:100%; ">
          <div ref="chart4" style="width:60%;height:160px"></div>
          <div
            style="width:40%;height:160px;padding: 31px 10px; display: flex; flex-wrap: wrap;justify-content: space-between;"
          >
            <div style="display: flex;" v-for="(item, index) in namedata">
              <div
                :style="{ backgroundColor: item.color }"
                class="dianidan"
              ></div>
              <div>
                <div style="font-size: 12px;margin-right: 7px; width: 61px;">
                  {{ item.name }}
                </div>
                <div style="font-size: 22px;color: #0F0F0F;">
                  {{ item.value }}
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import * as echarts from "echarts";
import { getSheet1FocusData } from "@/api/statistics";
export default {
  data() {
    return {
      date: new Date().getFullYear(),
      activeTab: 1,
      namedata: [
        { name: "一集中", value: 100, color: "#4E88F5" },
        { name: "二集中", value: 100, color: "#EEB74A" },
        { name: "三集中", value: 100, color: "#41B776" }
      ]
    };
  },

  mounted() {
    this.datalist();
  },
  methods: {
    async datalist(e) {
      const res = await getSheet1FocusData({
        year: this.date,
        sportTypeId: e || this.activeTab
      });
      if (res.data) {
        console.log(res.data);
      }
      // const series = res.data.series;
      // const xAxis = res.data.xAxis;
      // 基于准备好的dom，初始化echarts实例
      this.chart = echarts.init(this.$refs.chart);
      this.chart2 = echarts.init(this.$refs.chart2);
      this.chart3 = echarts.init(this.$refs.chart3);
      this.chart4 = echarts.init(this.$refs.chart4);
      // 指定图表的配置项和数据
      const option = {
        title: {
          text: "3326",
          left: "center",
          top: "42%",
          textStyle: {
            color: "#333",
            fontSize: 15,
            align: "center"
          }
        },
        tooltip: {
          trigger: "item"
        },

        legend: {
          top: "5%",
          left: "center",
          show: false
        },
        series: [
          {
            type: "pie",
            radius: ["40%", "70%"],
            avoidLabelOverlap: false,
            label: {
              show: false,
              position: "center"
            },
            radius: ["65%", "80%"],

            labelLine: {
              show: false
            },
            data: [
              { value: 1048, name: "省级重点(示范校)" },
              { value: 735, name: "地市级级重点(示范校)" },
              { value: 580, name: "区县级重点(示范校)" }
            ]
          }
        ]
      };
      const option2 = {
        title: {
          text: "3326",
          left: "center",
          top: "42%",
          textStyle: {
            color: "#333",
            fontSize: 15,
            align: "center"
          }
        },
        tooltip: {
          trigger: "item"
        },

        legend: {
          top: "5%",
          left: "center",
          show: false
        },
        series: [
          {
            type: "pie",
            radius: ["40%", "70%"],
            avoidLabelOverlap: false,
            label: {
              show: false,
              position: "center"
            },
            radius: ["65%", "80%"],

            labelLine: {
              show: false
            },
            data: [
              { value: 1048, name: "省级重点(示范校)" },
              { value: 735, name: "地市级级重点(示范校)" },
              { value: 580, name: "区县级重点(示范校)" }
            ]
          }
        ]
      };
      const option3 = {
        title: {
          text: "3326",
          left: "center",
          top: "42%",
          textStyle: {
            color: "#333",
            fontSize: 15,
            align: "center"
          }
        },
        tooltip: {
          trigger: "item"
        },

        legend: {
          top: "5%",
          left: "center",
          show: false
        },
        series: [
          {
            type: "pie",
            radius: ["40%", "70%"],
            avoidLabelOverlap: false,
            label: {
              show: false,
              position: "center"
            },
            radius: ["65%", "80%"],

            labelLine: {
              show: false
            },
            data: [
              { value: 1048, name: "省级重点(示范校)" },
              { value: 735, name: "地市级级重点(示范校)" },
              { value: 580, name: "区县级重点(示范校)" }
            ]
          }
        ]
      };
      const option4 = {
        title: {
          text: "3326",
          left: "center",
          top: "42%",
          textStyle: {
            color: "#333",
            fontSize: 15,
            align: "center"
          }
        },
        tooltip: {
          trigger: "item"
        },

        legend: {
          top: "5%",
          left: "center",
          show: false
        },
        series: [
          {
            type: "pie",
            radius: ["40%", "70%"],
            avoidLabelOverlap: false,
            label: {
              show: false,
              position: "center"
            },
            radius: ["65%", "80%"],

            labelLine: {
              show: false
            },
            data: [
              { value: 1048, name: "省级重点(示范校)" },
              { value: 735, name: "地市级级重点(示范校)" },
              { value: 580, name: "区县级重点(示范校)" }
            ]
          }
        ]
      };

      // 使用刚指定的配置项和数据显示图表。
      this.chart.setOption(option);
      this.chart2.setOption(option2);
      this.chart3.setOption(option3);
      this.chart4.setOption(option4);

      // 监听父元素大小变化 刷新图表
      var ro = new ResizeObserver(entries => {
        for (let entry of entries) {
          const cr = entry.contentRect;
          this.chart.resize();
          this.chart2.resize();
          this.chart3.resize();
          this.chart4.resize();
        }
      });

      ro.observe(this.$refs.chart);
      ro.observe(this.$refs.chart2);
      ro.observe(this.$refs.chart3);
      ro.observe(this.$refs.chart4);
    }
  }
};
</script>

<style>
.dianidan {
  width: 7px;
  height: 7px;
  margin-right: 5px;
}
</style>
